var express = require('express');
var router = express.Router();

var UserModel = require('../db/models/UserModel')

/* GET home page. */
router.get('/', function (req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get('/auth', function (req, res) {
  res.send('wecome to Auth');
});

router.post('/reg', function (req, res) {
  const { uname, upass } = req.body;

  new UserModel({
    username: uname,
    password: upass
  }).save().then(() => {
    res.send({
      code: 200,
      msg: '注册成功'
    })
  });
});
module.exports = router;
